package com.base.leetcode;

import com.base.dataStructure.Tree.TreeNode;

/**
 * @Author: hdhao
 * @Create: 2023/4/9 - 13:44
 * @Version: v1.0
 */
//二叉搜索树新增节点
public class Leetcode701 {

    public TreeNode insertIntoBST(TreeNode node, int val) {
        if (node == null) {
            return new TreeNode(val);
        }
        if (val < node.val) {
            node.left = insertIntoBST(node.left, val);
        } else if (node.val < val) {
            node.right = insertIntoBST(node.right, val);
        }
        return node;
    }
}
